﻿using CheatMenu.Managers;
using CheatMenu.Utils;
using UnityEngine;

namespace CheatMenu.Menus
{
    public class MenuCheat : MenuBase
    {
        private GUIStyle defaultFontButtonStyle;
        private GUIStyle defaultFontControlHeightButtonStyle;

        public MenuCheat() : base("CheatMenu", null)
        {
            Alignment = Alignment.TopCentre;
        }

        protected override Vector2 InitializeSize()
        => new Vector2(GUIManager.ControlWidth + (GUIManager.PaddingSize * 2), (GUIManager.ControlHeight * 2) + (GUIManager.PaddingSize * 2));

        protected override void InitializeGUI()
        {
            defaultFontButtonStyle = new GUIStyle(GUI.skin.button)
            {
                fontSize = GUIManager.ControlFontSize,
                margin = new RectOffset(0, 0, 0, 0),
                padding = new RectOffset(0, 0, 0, 0)
            };

            defaultFontControlHeightButtonStyle = new GUIStyle(GUI.skin.button)
            {
                fontSize = GUIManager.ControlFontSize,
                fixedHeight = GUIManager.ControlHeight
            };
        }

        protected override void MenuWindow(int id)
        {
            GUILayout.BeginVertical();
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();
                    GUILayout.BeginHorizontal(GUI.skin.box);
                    {
                        if (GUILayout.Button("Close", defaultFontControlHeightButtonStyle)) { Shown = false; }
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginVertical(GUI.skin.box);
                {
                    if (GUILayout.Button("State", defaultFontButtonStyle)) { MenuManager.GetMenu<MenuStateViewer>().ToggleShown(); }
                    if (GUILayout.Button("Commands", defaultFontButtonStyle)) { MenuManager.GetMenu<MenuCommands>().ToggleShown(); }
                    if (GUILayout.Button("Screenshot", defaultFontButtonStyle)) { MenuManager.GetMenu<MenuScreenshot>().ToggleShown(); }
                    if (GUILayout.Button("Config", defaultFontButtonStyle)) { MenuManager.GetMenu<MenuConfig>().ToggleShown(); }
                    if (GUILayout.Button("Debug", defaultFontButtonStyle)) { MenuManager.GetMenu<MenuDebug>().ToggleShown(); }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndVertical();
        }
    }
}
